Skip to content

fix: flush pending responses before runtime maintenance - #173

Open
hheei wants to merge 2 commits into
cortexkit:mainfrom
hheei:fix/pending-response-flush
Open

fix: flush pending responses before runtime maintenance#173
hheei wants to merge 2 commits into
cortexkit:mainfrom
hheei:fix/pending-response-flush

Conversation

@hheei

@hheei hheei commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Flush ready deferred responses before runtime maintenance and again afterward. This prevents a terminal foreground Bash task from waiting behind a synchronous runtime drain before its NDJSON response can be emitted.

The second flush preserves delivery for responses that become ready during maintenance. Runtime maintenance and task execution behavior are otherwise unchanged.

Fixes #172.

Regression coverage

  • Adds a pending-response ordering regression: a ready deferred response must be polled and written before configure-warning maintenance runs.
  • Updates the periodic-drain polling expectation for the new before/after flush behavior.

Validation

  • cargo +nightly-2026-04-29 test -p agent-file-tools pending_response_tests -- --nocapture
  • cargo +nightly-2026-04-29 test -p agent-file-tools decide_bash_step -- --nocapture
  • cargo +nightly-2026-04-29 build -p agent-file-tools --release --bin aft
  • Direct @cortexkit/aft-bridge smoke against the built binary: configure, Bash launch, terminal status, and output retrieval succeeded.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Flush ready pending responses before and after runtime maintenance to unblock terminal Bash NDJSON. Post-write LSP file-change notifications now skip cold starts by notifying only running servers.

  • Bug Fixes
    • Flush pending before drain_runtime_events, then flush again after.
    • Removes latency for terminal Bash NDJSON and preserves delivery for responses that become ready during maintenance.
    • LSP: notify_file_changed_if_running avoids starting servers on writes; explicit requests retain lazy startup.
    • Tests: add pending/maintenance ordering and twice-per-tick polling; add LSP no-cold-start regression. Fixes Deferred bash responses can be starved by runtime maintenance after task completion #172.

Written for commit 0904eee. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR adjusts response-flush ordering and avoids cold LSP startup during post-write notifications.

  • Flushes ready deferred responses immediately before runtime maintenance and again afterward.
  • Limits post-write file-change notifications to matching LSP servers that are already running.
  • Adds regression coverage for pending-response ordering and cold-server behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/aft/src/main.rs Flushes pending responses on both sides of runtime maintenance and adds ordering regression coverage.
crates/aft/src/lsp/manager.rs Adds a notification path that targets only matching LSP clients already present in the running-client map.
crates/aft/src/context.rs Routes best-effort post-write notifications through the running-server-only LSP path.

Reviews (2): Last reviewed commit: "fix(lsp): avoid cold starts after mutati..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deferred bash responses can be starved by runtime maintenance after task completion

1 participant